def calc_avg_value():
    total, counter, avg = 0, 0, None
    while True:
        value = yield avg
        total += value
        counter += 1
        avg = total / counter


def main():
    gen = calc_avg_value()
    gen.send(None)  # next(gen)
    print(gen.send(10))
    print(gen.send(20))
    print(gen.send(30))
    print(gen.send(30))
    print(gen.send(100))


if __name__ == '__main__':
    main()
